package assemble

import (
	"embed"
	"fmt"
	"gitee.com/git_public/vfaith/fount/frame"
	"github.com/shopspring/decimal"
	"log"
	"net/http"
	"os"
)

func InitServer(fs *embed.FS) {
	// 初始化项目自定义模块注册工厂，自动注册模块
	frame.InitFaithBuilder(fs) // 自定义模块注册工厂，实例方法会在启动时自动执行

	//修改decimal类型json转换配置
	decimal.MarshalJSONWithoutQuotes = true

	// 启动HTTP服务器
	port := fmt.Sprintf(":%s", os.Getenv("PORT"))
	log.Printf("--------------------------------------------------------")
	log.Printf("--------------------------------------------------------")
	log.Printf("--------------------------------------------------------")
	log.Printf("Server listening on port %s\n", port)
	log.Fatal(http.ListenAndServe(port, nil))
}
